package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: IndexServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-25
 * @Version: 1.0
 * Table: index
 * Comment:
 * 
 */
@Service
public class IndexServiceImpl extends IndexServiceCustomImpl implements IndexService {

    static {
        beanClassNameMap.put("index", "indexServiceImpl");
        listMethodNameMap.put("index", "listIndex");
        listMethodParameterClassNameMap.put("index", "IndexQueryRequest");
        updateMethodNameMap.put("index", "updateIndex");
        updateMethodParameterClassNameMap.put("index", "IndexUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addIndex(IndexAddRequest request) throws Exception {
        super.fixRequest("index", "add", request);
        return super.addIndex(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateIndex(IndexUpdateRequest request) throws Exception {
        Index record = null;
        super.fixRequest("index", "update", request, record);
        return super.updateIndex(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteIndex(IndexDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<Index> list = null;
            fixRequest("index", "delete", request, list);
        } else {
            fixRequest("index", "delete", request);
        }
        return super.deleteIndex(request);
    }

    @Override
    public IndexQueryResponse queryIndex(IndexQueryRequest request) throws Exception {
        IndexQueryResponse result = super.queryIndex(request);
        checkResult("index", "query", request, result);
        return result;
    }

    @Override
    public List<IndexQueryResponse> listIndex(IndexQueryRequest request) throws Exception {
        List<IndexQueryResponse> list = super.listIndex(request);
        checkResult("index", "list", request, list);
        return list;
    }

    @Override
    public Integer countIndex(IndexQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("index", "count", request);
        return super.countIndex(request);
    }

    @Override
    public BaseStatResponse statIndex(IndexQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("index", "stat", request);
        return super.statIndex(request);
    }

    @Override
    public List<Object> indexCheckInstall(BaseRequest request) throws Exception {
        super.fixRequest("index", "index_check_install", request);
        List<Object> result = super.indexCheckInstall(request);
        checkResult("index", "index_check_install", request, result);
        return result;
    }

}
